//
// Created by 伍泉 on 2024/6/7.
//

#ifndef HELLOFFMPEG_FFMPEGCODER_H
#define HELLOFFMPEG_FFMPEGCODER_H
#define INBUF_SIZE 4096
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
#include "FFmpegWrapper.h"
class FFmpegCodec {
public:
    FFmpegCodec();
    ~FFmpegCodec();

    bool decode(const char *inputFilename, const char *videoOutputFilename, const char *audioOutputFilename);
    bool encode(const char *videoInputFilename, const char *audioInputFilename, const char *outputFilename);

    bool convertAudioToAAC(const char *inputFilename, const char *outputFilename);
    bool convertVideoToH264(const char *inputFilename, const char *outputFilename);


    void decodeVideo(AVCodecContext *avCodecContext, AVFrame *avFrame, AVPacket *pkt, const char *filename);
    void decodeAudio(AVCodecContext *avCodecContext, AVPacket *pkt, AVFrame *avFrame, FILE *outfile);
    void saveYUV(AVFrame *avFrame, char *filename);
    int getSampleFmtFromName(const char **fmt, enum AVSampleFormat sample_fmt);


private:
    FFmpegWrapper* ffmpegWrapper;
};

#endif //HELLOFFMPEG_FFMPEGCODER_H
